import user, { UserTypes } from './modules/user';
import app, { AppTypes } from './modules/app';
import { createStore, useStore as baseUseStore, Store } from 'vuex';
import { cloneDeep } from 'lodash';

interface State { }
export interface AllState extends State {
    user: UserTypes;
    app: AppTypes;
}
const store = createStore<State>({
    state: {},
    mutations: {
        RESET_STATE(state: any) {
            for (const key in cloneState) {
                state[key] = cloneState[key];
            }
        }
    },
    modules: {
        user,
        app
    },
}) as Store<AllState>; //类型转换吧...
const cloneState: any = cloneDeep(store.state);//深度克隆state数据 用于退出重置
export default store;
export function useStore() {
    return baseUseStore<AllState>();
};